//
//  RankViewController.m
//  XingRun
//
//  Created by 赵颜彬 on 17/1/11.
//  Copyright © 2017年 赵颜彬. All rights reserved.
//

#import "RankViewController.h"

@interface RankViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong)UITableView *tableView;

@end

@implementation RankViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"排行";

    [self cretableView];
}
-(void)cretableView{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStyleGrouped];
    [self.view addSubview:_tableView];
    
    _tableView.tableHeaderView = [[RankHeadView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 70 * HEIGHT)];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[RankTableViewCell class] forCellReuseIdentifier:@"cell"];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    RankTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    if (indexPath.section == 0) {
        cell.number.text = @"23";
        cell.line.image = [UIImage imageNamed:@"线条2"];
        cell.km.text = @"17.88km";
        cell.quan.image = [UIImage imageNamed:@"挑战"];
    }if (indexPath.section == 1) {
        cell.number.text = [NSString stringWithFormat:@"%ld", indexPath.row + 1];
        cell.quan.image = [UIImage imageNamed:@"挑战"];
        if (indexPath.row <= 3) {
            cell.line.image = [UIImage imageNamed:@"线条1"];
            cell.km.text = @"28.88km";
        }else{
            cell.line.image = [UIImage imageNamed:@"线条2"];
            cell.km.text = @"24.88km";
        }
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;//设置
    return cell;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 2;
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    switch (section) {
            
        case 0:
            
            return  1;
            break;
            
        case 1:
            return 10;
            break;
        
            
        default:
            
            return 0;
            
            break;
            
    }

}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50 * HEIGHT;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
